<template>
  <div class="map box bg clmcenter">
    <!-- 中英文切换 -->
    <div class="changelangbox">
      <div
        v-for="item in langlist"
        :key="item.id"
        :class="[
          item.id,
          item.id == 'en' ? 'clmcenter' : '',
          item.active ? 'active' : '',
        ]"
        @click="changeLang(item.id)"
      >
        <span>{{ item.name }}</span>
      </div>
    </div>
    <div class="container clmcenter animate__animated animate__fadeIn">
      <!-- 1-3层 展开收起控制 -->
      <div
        class="tipsbox headtipbox"
        @click="topisexpand = !topisexpand"
        :style="{
          right: topisexpand ? '0' : '2rem',
          top: topisexpand ? '0.3rem' : '2rem',
          // 'transition-delay': topisexpand ? '0s' : '0.6s',
        }"
      >
        <div class="desc">
          <p>先进的表面处理<br />和涂装工艺模拟生产线</p>
        </div>
        <div class="clicktip rowcenter">
          <span>点击{{ topisexpand ? "收起" : "展开" }}</span>
          <img src="@/assets/img/map/hand.png" class="hand" />
        </div>
      </div>
      <!-- 内容区 -->
      <div class="mapcontain clmstart">
        <!-- 1-3层 -->
        <div class="mapinfo maptop clmstart">
          <div
            class="mitem head"
            :style="{
              top: topisexpand ? '0' : '7rem',
              // 'transition-delay': topisexpand ? '0s' : '0.6s',
            }"
          >
            <div class="mcont">
              <img src="@/assets/img/map/head.png" class="floor" />
            </div>
          </div>
          <div
            class="mitem f1"
            :style="{
              top: topisexpand ? '-2.5rem' : '0',
              left: topisexpand ? '-14.2rem' : '0',
              // 'transition-delay': topisexpand ? '0s' : '0.4s',
            }"
            @click="toInfo('itemA', 1)"
          >
            <div class="mcont">
              <img src="@/assets/img/map/f1.png" class="floor" />
              <div
                :class="[
                  'minfo animate__animated',
                  topisexpand
                    ? 'animate__fadeIn animate__slow'
                    : 'animate__fadeOut faster',
                ]"
              >
                <img src="@/assets/img/map/p1.png" class="pimg" />
                <img src="@/assets/img/map/jt.png" class="jt" />
                <p class="ptxt">表面处理实验室</p>
              </div>
            </div>
          </div>
          <div
            class="mitem f2"
            :style="{
              top: topisexpand ? '13rem' : '0',
              left: topisexpand ? '14.2rem' : '0',
              // 'transition-delay': topisexpand ? '0s' : '0s',
            }"
            @click="toInfo('itemB', 2)"
          >
            <div class="mcont">
              <img src="@/assets/img/map/f1.png" class="floor" />
              <div
                :class="[
                  'minfo animate__animated',
                  topisexpand
                    ? 'animate__fadeIn animate__slow'
                    : 'animate__fadeOut faster',
                ]"
              >
                <img src="@/assets/img/map/p2.png" class="pimg" />
                <img src="@/assets/img/map/jt.png" class="jt" />
                <p class="ptxt">粉末喷房</p>
              </div>
            </div>
          </div>
          <div class="mitem f3">
            <div class="mcont">
              <img src="@/assets/img/map/f2.png" class="floor" />
              <div
                :class="[
                  'minfo animate__animated',
                  topisexpand
                    ? 'animate__fadeIn animate__slow'
                    : 'animate__fadeOut faster',
                ]"
                @click="toInfo('itemC', 3)"
              >
                <img src="@/assets/img/map/p3.png" class="pimg" />
                <img src="@/assets/img/map/jt.png" class="jt" />
                <p class="ptxt">浸涂电泳模拟线</p>
              </div>
            </div>
          </div>
        </div>
        <!-- 4-8层 -->
        <div class="mapinfo mapbottom clmstart">
          <div class="mitem f4">
            <div
              class="mcont"
              :style="{
                top: botisexpand ? '2rem' : '0',
                left: botisexpand ? '-14.2rem' : '0',
              }"
              @click="toInfo('itemD', 4)"
            >
              <img src="@/assets/img/map/f3.png" class="floor" />
              <div
                :class="[
                  'minfo animate__animated',
                  botisexpand
                    ? 'animate__fadeIn animate__slow'
                    : 'animate__fadeOut faster',
                ]"
              >
                <img src="@/assets/img/map/p4.png" class="pimg" />
                <img src="@/assets/img/map/jt.png" class="jt" />
                <p class="ptxt">盐雾测试实验室</p>
              </div>
            </div>
          </div>
          <div class="mitem f5" :style="{ 'z-index': botisexpand ? '9' : '5' }">
            <div
              class="mcont"
              :style="{
                top: botisexpand ? '8.3rem' : '0',
                left: botisexpand ? '0' : '0',
              }"
              @click="toInfo('itemE', 5)"
            >
              <img src="@/assets/img/map/f3.png" class="floor" />
              <div
                :class="[
                  'minfo animate__animated',
                  botisexpand
                    ? 'animate__fadeIn animate__slow'
                    : 'animate__fadeOut faster',
                ]"
              >
                <img src="@/assets/img/map/p5.png" class="pimg" />
                <img src="@/assets/img/map/jt.png" class="jt" />
                <p class="ptxt">环境测试实验室</p>
              </div>
            </div>
          </div>
          <div class="mitem f6">
            <div
              class="mcont"
              :style="{
                top: botisexpand ? '16rem' : '0',
                left: botisexpand ? '14.2rem' : '0',
              }"
              @click="toInfo('itemF', 6)"
            >
              <img src="@/assets/img/map/f3.png" class="floor" />
              <div
                :class="[
                  'minfo animate__animated',
                  botisexpand
                    ? 'animate__fadeIn animate__slow'
                    : 'animate__fadeOut faster',
                ]"
              >
                <img src="@/assets/img/map/p6.png" class="pimg" />
                <img src="@/assets/img/map/jt.png" class="jt" />
                <p class="ptxt">综合仪器分析室</p>
              </div>
            </div>
          </div>
          <div class="mitem f7">
            <div
              class="mcont"
              :style="{
                top: botisexpand ? '9rem' : '0',
                left: botisexpand ? '-14.2rem' : '0',
              }"
              @click="toInfo('itemG', 7)"
            >
              <img src="@/assets/img/map/f4.png" class="floor" />
              <div
                :class="[
                  'minfo animate__animated',
                  botisexpand
                    ? 'animate__fadeIn animate__slow'
                    : 'animate__fadeOut faster',
                ]"
              >
                <img src="@/assets/img/map/p7.png" class="pimg" />
                <img src="@/assets/img/map/jt.png" class="jt" />
                <p class="ptxt">荧光光谱实验室</p>
              </div>
            </div>
          </div>
          <div class="mitem f8">
            <div
              class="mcont"
              :style="{
                bottom: botisexpand ? '-14rem' : '0',
              }"
              @click="toInfo('itemH', 8)"
            >
              <img src="@/assets/img/map/f4.png" class="floor" />
              <div
                :class="[
                  'minfo animate__animated',
                  botisexpand
                    ? 'animate__fadeIn animate__slow'
                    : 'animate__fadeOut faster',
                ]"
              >
                <img src="@/assets/img/map/p8.png" class="pimg" />
                <img src="@/assets/img/map/jt.png" class="jt" />
                <p class="ptxt">扫描电镜实验室</p>
              </div>
            </div>
          </div>
          <div class="mitem foot">
            <div
              class="mcont"
              :style="{
                bottom: botisexpand ? '-14rem' : '0',
              }"
            >
              <img src="@/assets/img/map/foot.png" class="floor" />
            </div>
          </div>
        </div>
      </div>
      <!-- 4-8层 展开收起控制-->
      <div
        class="tipsbox foottipbox"
        @click="botisexpand = !botisexpand"
        :style="{
          left: botisexpand ? '0' : '4rem',
          bottom: botisexpand ? '0' : '8rem',
        }"
      >
        <div class="desc">
          <p>多种技术性能设备<br />提供全面测试和服务</p>
        </div>
        <div class="clicktip rowcenter">
          <span>点击{{ botisexpand ? "收起" : "展开" }}</span>
          <img src="@/assets/img/map/hand.png" class="hand" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from "vant";
export default {
  data() {
    return {
      topisexpand: false,
      botisexpand: false,
      langlist: [
        { id: "cn", name: "中文", active: true },
        { id: "en", name: "EN", active: false },
      ],
    };
  },
  created() {
    // let times = this.$route.query.times;
    // if (times == "0") {
    //   this.topisexpand = false;
    //   this.botisexpand = false;
    // } else {
    //   this.topisexpand = true;
    //   this.botisexpand = true;
    // }
  },
  methods: {
    toInfo(id, floorNo) {
      if (floorNo <= 3 && !this.topisexpand) {
        return Toast("请先展开地图！");
      }
      if (floorNo >= 4 && !this.botisexpand) {
        return Toast("请先展开地图！");
      }
      this.$store.commit("updateCnScenceCtrlShow", false);
      this.$router.replace({
        path: `/cn/lab/${id}`,
      });
    },
    // 切换语言
    changeLang(id) {
      this.langlist.forEach((item) => {
        if (item.id == id) {
          item.active = true;
          if (id === "en") {
            this.$router.replace("/en/map");
          }
        } else {
          item.active = false;
        }
      });
      // this.langlist.find((item) => item.id == id).active = true;
    },
  },
};
</script>

<style lang="less" scoped>
.map {
  img {
    pointer-events: none;
  }
  .container {
    position: relative;
    width: 712px;
    height: 1097px;
    // border: 1px solid red;
    // box-sizing: border-box;
    .mapcontain {
      margin-bottom: 7rem;
      .maptop {
        height: 351px;
      }
      .mapbottom {
        height: 298.2px;
      }
      .mapinfo {
        position: relative;
        .mitem {
          position: relative;
          width: 256px;
          height: 184px;
          margin-top: -8.5rem;
          transition: all 0.4s linear;
          .mcont {
            position: absolute;
            width: 100%;
            height: 100%;
            transition: all 0.4s linear;
            z-index: 9;
            .floor {
              width: 100%;
              vertical-align: middle;
            }
            .minfo {
              position: absolute;
              top: 0;
              left: 0;
              width: 100%;
              height: 100%;
              .pimg {
                width: 100%;
              }
              .ptxt {
                position: absolute;
                font-size: 1.15rem;
                font-weight: bold;
              }
              .jt {
                position: absolute;
                width: 23px;
              }
            }
          }
        }
        .foot {
          z-index: 1;
        }
        .f8 {
          z-index: 2;
          .mcont {
            .minfo {
              .pimg {
                margin-top: -4rem;
              }
              .jt {
                left: 6rem;
                top: -2.5rem;
              }
              .ptxt {
                top: -2.5rem;
                left: 7.8rem;
              }
            }
          }
        }
        .f7 {
          z-index: 3;
          .mcont {
            .minfo {
              .pimg {
                margin-top: -2rem;
              }
              .jt {
                left: 0.5rem;
                top: -1rem;
              }
              .ptxt {
                top: -3rem;
                left: 0.5rem;
              }
            }
          }
        }
        .f6 {
          z-index: 4;
          .mcont {
            .minfo {
              .pimg {
                margin-left: 0.5rem;
                margin-top: -2.3rem;
              }
              .jt {
                left: 1.5rem;
                top: -1rem;
              }
              .ptxt {
                top: -2.5rem;
                left: 1.5rem;
              }
            }
          }
        }
        .f5 {
          .mcont {
            .minfo {
              .pimg {
                margin-top: -3.5rem;
                margin-left: -0.3rem;
              }
              .jt {
                right: 4rem;
                top: -1.5rem;
              }
              .ptxt {
                top: -3.5rem;
                right: 0.6rem;
              }
            }
          }
        }
        .f4 {
          z-index: 6;
          .mcont {
            .minfo {
              .pimg {
                margin-left: 0.5rem;
                margin-top: -2.3rem;
              }
              .jt {
                left: 0.5rem;
                top: -1rem;
              }
              .ptxt {
                top: -3rem;
                left: 0.5rem;
              }
            }
          }
        }
        .f3 {
          height: 203px;
          z-index: 7;
          .mcont {
            .minfo {
              .pimg {
                margin-left: -0.5rem;
                margin-top: -3rem;
              }
              .jt {
                right: 0.8rem;
                top: 0;
              }
              .ptxt {
                top: 0;
                right: -7.5rem;
              }
            }
          }
        }
        .f2 {
          z-index: 8;
          .mcont {
            .minfo {
              .pimg {
                margin-left: -0.5rem;
                margin-top: -3rem;
              }
              .jt {
                right: 1.5rem;
                top: -0.5rem;
              }
              .ptxt {
                top: -2.5rem;
                right: 0;
              }
            }
          }
        }
        .f1 {
          z-index: 9;
          // margin-top: -9.7rem;
          margin-top: -10.5rem;
          .mcont {
            .minfo {
              .pimg {
                margin-left: 0.5rem;
                margin-top: -2.3rem;
              }
              .jt {
                left: 0.5rem;
                top: -1rem;
              }
              .ptxt {
                top: -3rem;
                left: 0.5rem;
              }
            }
          }
        }
        .head {
          pointer-events: none;
          width: 295px;
          height: 224px;
          z-index: 10;
          margin-top: 0;
          .mcont {
            top: -7rem;
          }
        }
        .foot {
          width: 290px;
          height: 217px;
          margin-top: -9.3rem;
          .mcont {
            .floor {
              filter: drop-shadow(80px -38px 30px #bdc4f27e);
            }
          }
        }
      }
    }
    .tipsbox {
      position: absolute;
      width: 213px;
      transition: all 0.5s;
      .desc {
        width: 100%;
        height: 130px;
        display: flex;
        justify-content: center;
        align-items: flex-end;
        p {
          font-size: 1.15rem;
          text-align: right;
          font-weight: bold;
          padding-bottom: 1.5rem;
        }
      }
      .clicktip {
        padding-top: 0.5rem;
        span {
          font-size: 1.3rem;
        }
        .hand {
          width: 36px;
          padding-left: 0.5rem;
        }
      }
    }
    .headtipbox {
      top: 0;
      right: 0;
      .desc {
        background: url("@/assets/img/map/cloud1.png") no-repeat;
        background-size: 100% 100%;
      }
    }
    .foottipbox {
      left: 0;
      bottom: 0;
      .desc {
        background: url("@/assets/img/map/cloud2.png") no-repeat;
        background-size: 100% 100%;
      }
    }
  }
}
@media only screen and (min-height: 1400px) {
  .map {
    .container {
      margin-bottom: 3rem;
    }
  }
}
</style>
